<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
    <div id="app">
        <p>元和角的转换</p>
        <p>元：<input type="text" v-model="yuan"></p>
        <p>角：<input type="text" v-model="jiao"></p>
    </div>
<!--引入vue文件-->
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
    const vm = Vue.createApp({
        data() {
            return {
                yuan: 0,
                jiao: 0
            }
        },
        methods: {
            method1:function(val, oldVal){
                this.jiao = val * 10;
            },
            method2:function(val, oldVal){
                this.yuan = val / 10;
            }
        },
        watch: {
            // 监听yuan属性，yuan变化时，使jiao属性等于yuan*10
            yuan: "method1",
            // 监听jiao属性，jiao变化时，使yuan属性等于jiao/10
            jiao: "method2"
        }
    }).mount('#app');
</script>


</body>
</html>
